 // Prevent conflicts with the Scriptaculous AJAX library.
 //var $ = jQuery.noConflict();
   
    $(document).ready(
        function(){ 
            /* 
                Hide the opaque background on page load 
                and fade it to 0% opacity
            */
			if(document.getElementById("opaque") != null){
				$("#opaque").css("opacity", 0);
				$("#opaque").hide();				
			}
            var bMenuActive = false;
            
             /* Hide and show the opaque background when the menu is in focus */
            $("#nav").hover(
            
                function()
                {				
                    ShowOpaque();            
                },            
                function()
                {
                    HideOpaque();
                }

            );
            
			/*
			For IE6.0 only since it doesn't respond to li:hover
			*/
			if(jQuery.browser.version == 6.0 &&  jQuery.browser.msie)
			{
				$("#share_digg a").css("margin-bottom","3.2em");
				$("#last_foot").hover(
	                function(){
						$("#share_popup").show();
	                },
	                
	                function(){
						$("#share_popup").hide();
	                }           
				);
				$(".corner_tab").hover(
	            
	                function(){
						AnimateHoveredTab(true, $(this));                 
	                },
	                
	                function(){
	                    AnimateHoveredTab(false, $(this));   
	                }           

	            );
			}

            
            $("ul#nav > li").hover(
                function(){
					AnimateSelectedTab(true, $(this));                 
                },
                
                function(){
                    AnimateSelectedTab(false, $(this));   
                }           
            
            );           
           
           /*
			For IE6.0 only since it doesn't respond to li:hover
			*/
		   function AnimateHoveredTab(bHoverStateOn, objCornerTabDiv)
		   {
                if(objCornerTabDiv != undefined){
					if(bHoverStateOn){
							$(objCornerTabDiv).find(".cornertab_href").css("height","7em");
					}else{
							//$(objCornerTabDiv).find(".cornertab_href").css("height","6.2em");
					}
				}                 
		   }
		   
           function AnimateSelectedTab(bHoverStateOn, objListItem)
           {
                var strClass = ""; 
                if(objListItem != undefined)
                    strClass = $(objListItem).attr('class');    

                if(bHoverStateOn)
                    ShowOpaque();                 
                    
                var oSelectedTabHref = $("#nav .selected .maintab_href");
				
                // One of the tabs is in hover state on                
                if(bHoverStateOn)
                {                    
                    // If it's one of the other tabs (check for the "selected class"; must be index of in case sfhover)
                    if(strClass.indexOf('selected') == -1)
                    {                 
                        $(oSelectedTabHref).css("opacity", "0.5");
                        $(oSelectedTabHref).css("height","5em");                    
						
                    }
                    else
                    {  
                        $(oSelectedTabHref).css("opacity",1);                        
                        $(oSelectedTabHref).css("height","9.1em");
						
                    }
                }else
                {  
                    $(oSelectedTabHref).css("opacity",1);
                    $(oSelectedTabHref).css("height","9.1em");
					
                }
           }           
                
           var bHiding = false;
           var bShowing = false;
           var sLastAction
            
           // Hide the opaque panel when the fade is complete to prevent element z-index problems.
           function HideOpaque()
           {
                var bForce = false;
                var speed = 150;
                
                // Sometimes we need to force; 
                // e.g. if we have overlapping events, and the 2nd event finishing doesn't correspond with bMenuActive
                if(arguments[0] != undefined)
                    bForce = arguments[0];
                    
                if(bForce)
                    speed = 50; 
                    
                if(!bMenuActive && !bForce)
                    return;
                bMenuActive = false;
                //Audit("bMenuActive: false");
                if(bHiding && !bForce) 
                    return;
                bHiding = true;                
				$("#opaque").css("opacity", 0);
				$("#opaque").hide();	
				/*
					$("#opaque").fadeTo(speed, 0, function(){ 
					$("#opaque").css("z-index", -1); 
					bHiding = false; 
					if(bMenuActive) { ShowOpaque(true); } } );                 
					*/
                AnimateSelectedTab(false);     
                                
           }
           
           
           function ShowOpaque()
           { 
				
				// Apply a fudge factor to fire fox to prevent scroll bars...
				if(!jQuery.browser.msie)
				{
					//$("#opaque").css("width",pageWidth() - 17);
				}
   				
				// Apply a height tweak to all browsers to cover lower region of the page...
				//$("#opaque").css("height",pageHeight() + 100);					

                var bForce = false;
                var speed = 250;
                
                // Sometimes we need to force; 
                // e.g. if we have overlapping events, and the 2nd event finishing doesn't correspond with bMenuActive
                if(arguments[0] != undefined)
                    bForce = arguments[0];
                    
                if(bForce)
                    speed = 50; 
                                                            
                if(bMenuActive && !bForce)
                    return;
                $("#opaque").css("z-index", 99);    
                bMenuActive = true;
                //Audit("bMenuActive: true");
                if(bShowing && !bForce)
                    return;            
                bShowing = true; 
                bHiding = false;  
                //Audit("ShowOpaque: start. bForce: " + bForce);
                $("#opaque").show();				
                $("#opaque").fadeTo(speed, 0.5, function() { bShowing = false;/* Audit("ShowOpaque: finish (" + speed + "). bMenuActive: " + bMenuActive); */ if(!bMenuActive) { HideOpaque(true); }} );
                
           }
           
           function Audit(msg)
           {
                //$("#debug").html(msg + "<br/>" + $("#debug").html() );       
           }  

          /*
	  $("form#SearchPanel_search_widget_form").eq(0).replaceWith("<form id='SearchPanel_search_widget_form' action='/Societyandenvironment/Ourapproach/Sustainabilityreport/searchresults.aspx' method='post'><div><label for='text' style='display: none;'>text</label><input id='text' type='text' name='ERsearch_text' onfocus='if(this.value=='Search using a keyword')this.value=''' value='Search using a keyword'/><a id='SearchPanel_societyhub_search_button' title='Search Environment Report' href='javascript:document.forms.SearchPanel_search_widget_form.submit();'><img id='img_PSR_fd66bd92-4726-4615-9bcd-4a8d1ccdfc51' width='33' height='22' alt='' style='margin: 0px; float: none;' src='/Templates/images08/go_button.gif'/></a></div></form>")
	  $("form#SearchPanel_search_widget_form").eq(0).replaceWith("<form id='SearchPanel_search_widget_form' action='/Societyandenvironment/Ourapproach/Sustainabilityreport/searchresults.aspx' method='post'><div><label for='text' style='display: none;'>text</label><input id='text' type='text' name='ERsearch_text' value='Search using a keyword'/><a id='SearchPanel_societyhub_search_button' title='Search Environment Report' href='javascript:document.forms.SearchPanel_search_widget_form.submit();'><img id='img_PSR_fd66bd92-4726-4615-9bcd-4a8d1ccdfc51' width='33' height='22' alt='' style='margin: 0px; float: none;' src='/Templates/images08/go_button.gif'/></a></div></form>")
	   
         $("form#SearchPanel_search_widget_form").eq(0).replaceWith("<form id='SearchPanel_search_widget_form' action='/Societyandenvironment/Ourapproach/Sustainabilityreport/searchresults.aspx' method='post'><div><label for='text' style='display: none;'>text</label><input id='searchpaneltext' type='text' name='ERsearch_text' onfocus='if(this.value==\"Search using a keyword\"){this.value=\"\"}' value='Search using a keyword'/><a id='SearchPanel_societyhub_search_button' title='Search Environment Report' href='javascript:document.forms.SearchPanel_search_widget_form.submit();'><img id='img_PSR_fd66bd92-4726-4615-9bcd-4a8d1ccdfc51' width='33' height='22' alt='' style='margin: 0px; float: none;' src='/Templates/images08/go_button.gif'/></a></div></form>")
	     */         

    });
    
// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}
                    	
    
          